import StrUtil from './StrUtil'

export default class MathUtil {
    /**
     * 将所有值转换为float
     */
    static getNumber(val: any, fixed?: number) {
        let valt = parseFloat(val)
        valt = StrUtil.isNull(valt) ? 0 : valt
        return fixed ? parseFloat(valt.toFixed(fixed)) : valt
    }

    /**
     * 获取两个整数之间的随机数
     */
    static getRandomInt(min: number, max: number) {
        min = Math.ceil(min)
        max = Math.floor(max)
        return Math.floor(Math.random() * (max - min + 1)) + min
    }
}
